package com.haynes.social.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 统一结果返回类
 * @Author Haynes
 * @Date 2023/5/26 15:21
 * @PackageName:com.haynes.store.common
 * @ClassName: Result
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> implements Serializable {
    /**
     * 响应码
     */
    private Integer code;
    /**
     * 响应消息
     */
    private String message;
    /**
     * 响应数据
     */
    private T data;


    public static <T> Result<T> success(){
        return new Result<T>(200, null, null);
    }
    public static <T> Result<T> success(T data){
        return new Result<T>(200, null, data);
    }
    public static <T> Result<T> error(String errorMsg){
        return new Result<T>(500, errorMsg, null);
    }
}
